package com.pzl.library;

import com.pzl.library.base.Node;

/**
 * Created by zl.peng on 2016-03-25.
 */
public class SimpleNode extends Node {
    private String text;

    public SimpleNode(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(text);
        if (children.size() == 0) return sb.toString();
        sb.append("---------------->");
        for (int i = 0; i < children.size(); i++) {
            sb.append("\n");
            SimpleNode child = (SimpleNode) children.get(i);
            for (int j = 0; j < child.level; j++) {
                sb.append("...");
            }
            sb.append(child.toString());
        }
        return sb.toString();
    }

    public String print() {
        return isSelected() == true ? "[" + text + "]√" : "[" + text + "]×";
    }
}
